import { useDispatch } from "react-redux";
import { Dispatch } from "redux";

export default function useToast() {
  const dispatch = useDispatch<Dispatch<IToastAction>>();

  return (type: AlertColor, msg: string) => {
    dispatch({
      type: "SHOW_TOAST",
      payload: {
        msg: msg,
        type: type,
      },
    });
  };
}
